|----Created by Crystane out of numerous snippets from other authors, thx to them.
|----For www.redguides.com
|----I know there are plugins out for it, but plugins break with numerous patches where a macro continues. + I can fix macros, not plugins.
|----[05-07-07]
|----Itemcast.inc
|----IMPORTANT be careful and try to avoid putting in just a /doevents , especially when the Macro useing this inc uses the Event AddALVoid
Sub ItemCaster(ItemToCast)
/if (!${Defined[ICcastReturn]}) /declare ICcastReturn string outer X
/varset ICcastReturn X
|/echo Looking to find ${ItemToCast}
/call ItemFinder "${ItemToCast}"
|/echo Found the Item ${Macro.Return}
/if (${Macro.Return.Equal["INVENTORY"]}) {
	/if (${FindItem[${ItemToCast}].EffectType.Equal[Click Inventory]}) /call CastInInv "${ItemToCast}"
	/if (${FindItem[${ItemToCast}].EffectType.Equal[Click Worn]}) /call CastWornfromInv "${ItemToCast}"
}
/if (${Macro.Return.Equal["BAGGED"]}) {
	/if (${FindItem[${ItemToCast}].EffectType.Find[Click]}) /call CastWornfromInv "${ItemToCast}"
}
/if (${Macro.Return.Equal["EQUIPPED"]}) {
	/call cast "${ItemToCast}" item
	/varset ICcastReturn ${Macro.Return}
}
/if (${ICcastReturn.Equal[X]} && ${Spell[${ItemToCast}].CastTime}<0.01) /varset ICcastReturn CAST_SUCCESS
/if (${ICcastReturn.Equal["NOTFOUND"]}) /echo You seam to not posses that item.
/return ${ICcastReturn}

sub ItemFinder(ItemToCast) 
/declare bag int local ${FindItem[${ItemToCast}].InvSlot.Pack} 
/declare slot int local ${FindItem[${ItemToCast}].InvSlot} 
/declare equipslot string local ${FindItem[${ItemToCast}].WornSlot[1].Name} 
/declare equipslot2 string local ${FindItem[${ItemToCast}].WornSlot[2].Name} 
/declare equipslot3 string local ${FindItem[${ItemToCast}].WornSlot[3].Name} 
/if ((${bag}==0)&&(${slot}==0)) /return NOTFOUND 
/if (${Me.Inventory[${equipslot}].Name.Equal[${ItemToCast}]}) /return EQUIPPED 
/if (${Me.Inventory[${equipslot2}].Name.Equal[${ItemToCast}]}) /return EQUIPPED 
/if (${Me.Inventory[${equipslot3}].Name.Equal[${ItemToCast}]}) /return EQUIPPED 
/if (${bag}==0 && ${slot}>0) /return INVENTORY 
/if (${bag}>0 && ${slot}>0) /return BAGGED 
/return

Sub CastWornfromInv(ItemToCast)
/declare oldItemName string local ${InvSlot[${FindItem[${ItemToCast}].WornSlot[1]}].Item.Name}
/declare slotName string local ${FindItem[${ItemToCast}].WornSlot[1]}
/exchange "${ItemToCast}" ${slotName}
/call cast "${ItemToCast}" item
/varset ICcastReturn ${Macro.Return}
/delay 5
:wait1 
/if (${Me.Casting.ID} || ${Me.Moving}) /goto :wait1 
/delay 5
/exchange "${oldItemName}" ${slotName}
/return

Sub CastInInv(ItemToCast) 
/call cast "${ItemToCast}" item
/varset ICcastReturn ${Macro.Return}
/return